<?php
	defined("AT_EXE") or die ("CORE VARIABLE IS NOT DEFINED.");
	class Request {
		private $comp = array("page"=>"index");
		private $vars = array();
		private $level = array();
		private $access=true;
		public function __construct($comp=array(),$level=array(),$vars=array()){
			!empty($comp)?$this->comp=$comp:false;
			!empty($vars)?$this->vars=$vars:false;
			!empty($level)?$this->level=$level:false;
			if(is_array($level)&&!empty($level)&&isset($level["level"])){
				foreach($level["level"] as $key=>$val){
					if($key==$val) $this->access=true;
					else $this->access=false;
				}
			}
		}
		public function getRedirectPath(){
			return $this->level["controller"];
		}
		public function setComponent($comp=array()){
			if(is_array($comp)&&!empty($comp))$this->comp=$comp;
		}
		public function setVars($vars=array()){
			$this->vars=empty($vars)?$this->vars:$vars;
		}
		public function setLevel($level=array()){
			$this->level=empty($level)?$this->level:$level;
		}
		public function getAccess(){
			return $this->access;
		}
		public function getController(){
			foreach($this->comp AS $controller => $action ){
				return $controller;
			}
		}
		public function getAction(){
			foreach($this->comp AS $controller => $action ){
				return $action;
			}
		}
		public function getLevel(){
			return $this->level;
		}
		public function getStringLevel(){
			foreach($this->level AS $key => $val ){
				return $key.$val;
			}
		}
		public function getVar($name=""){
			return $var_name===""?NULL:(isset($this->vars[$var_name])?$this->vars[$var_name]:NULL);
		}
		public function getVars(){
			return $this->vars;
		}
		public function toString(){
			return array($this->comp,$this->vars);
		}
	}
